<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户管理</title>
<link rel="stylesheet" type="text/css"
	href="../../css/themes/default/easyui.css" />
<link rel="stylesheet" type="text/css" href="../../css/themes/icon.css" />
<script type="text/javascript" src="../../js/jquery-1.7.2.js"></script>
<script type="text/javascript"
	src="../../js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="../../js/ListData.js"></script>
<script type="text/javascript">
	$(function() {
		$('#tt').datagrid({
			singleSelect : true,
			rownumbers : true,
			onClickRow : function(rowIndex, rowData) {
				execFrame(function(wind) {
					wind.alterAction("../../member/achievement/update");
					wind.clearForm();
					wind.loadData(rowData);
				})
			}
		});
		loadData();
		$('#panel_edit').panel({});

		loadData();
	});
	function execFrame(fun) {
		var frame = $("iframe", $("#panel_edit").panel())[0];
		var wind = frame.contentWindow;
		if (wind && wind.loadData) {
			fun(wind);
		} else {
			if (frame.attachEvent) {
				frame.attachEvent("onload", function() {
					fun(frame.contentWindow);
				});
			} else {
				frame.onload = function() {
					fun(frame.contentWindow);
				};
			}
		}
	}
	function loadData() {
		$.get("../../member/achievement/find", {
			id : window.top.cur_object.id
		}, function(str) {
			if (typeof str == "object" && str instanceof Array) {
				$('#tt').datagrid("loadData", str);
			}
		})
	}
	function add() {
		execFrame(function(wind) {
			wind.alterAction("../../member/achievement/add");
			wind.clearForm();
			wind.loadData({
				memberID : window.top.cur_object.id
			});
		})
	}
	function remove() {
		var node = $('#tt').datagrid("getSelected");
		if (node == null) {
			return;
		}
		if (confirm("删除后不可恢复，请确认！")) {
			$.post("../../member/achievement/delete", node, function(str) {
				loadData();
				execFrame(function(wind) {
					wind.clearForm();
				})
			})
		}
	}
	function refresh() {
		try {
			loadData();
		} catch (e) {
		}
	}
	function achievementDegreeFormatter(value) {
		return commonFormatter(list_achievement_degree, value);
	}
	function achievementTypeFormatter(value) {
		return commonFormatter(list_achievement_type, value);
	}
	function commonFormatter(list, value) {
		for ( var i = 0; i < list.length; i++) {
			if (list[i].value == value) {
				return list[i].text;
			}
		}
		return value;
	}
</script>
<style type="text/css">
body {
	text-align: center;
	margin: 0px;
	padding: 0px;
	width: 100%;
	height: 100%;
}
</style>
</head>
<body style="margin: 0">
	<table id="tt" class="easyui-datagrid" data-options="toolbar:'#tb'"
		style="width: 100; height: 200px;">
		<thead>
			<tr>
				<th data-options="field:'achievementName',width:80">成果名称</th>
				<th
					data-options="field:'achievementDegree',width:80,formatter:achievementDegreeFormatter,editor:{
							type:'combobox'}">级别</th>
				<th
					data-options="field:'achievementType',width:80,formatter:achievementTypeFormatter,editor:{
							type:'combobox'}">类型</th>
				<th data-options="field:'acquireDate',width:80">获取时间</th>
			</tr>
		</thead>
	</table>
	<div id="tb">
		<div style="float: left">
			<a href="#" class="easyui-linkbutton"
				data-options="iconCls:'icon-add',plain:true" id="but_add"
				onclick="javascript:add()">添加</a>
		</div>
		<div style="float: left">
			<a href="#" class="easyui-linkbutton"
				data-options="iconCls:'icon-remove',plain:true" id="but_remove"
				onclick="javascript:remove()">删除</a>
		</div>
		<div style="float: left">
			<a href="#" class="easyui-linkbutton"
				data-options="iconCls:'icon-reload',plain:true" id="but_refresh"
				onclick="javascript:refresh()">刷新</a>
		</div>
	</div>
	<hr />
	<div id="panel_edit" style="width: 800px; height: 300px">
		<iframe id="frame_edit" width="100%" height="100%" frameborder="0"
			src="member_achievement_edit.jsp"></iframe>
	</div>

</body>
</html>